package com.example.sync.controller;

import com.example.sync.pojo.User;
import com.example.sync.service.AsyncService;
import com.example.sync.service.UserService;
import com.example.sync.utils.GenerateQrCodeUtils;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.File;

/**
 * @author gaofeng
 * @date 2022年07月03日 8:34
 */
@RestController
@EnableConfigurationProperties
public class AsyncController {

    @Resource
    private AsyncService asyncService ;

    @Resource
    private UserService userService ;

    @PostMapping("/sendMail")
    public String sendMail() {
        asyncService.sendMail();
        return "OK!" ;
    }

    @PostMapping("/getUserById")
    public User getUserById() {
        return userService.getUserById(1) ;
    }

    @GetMapping("/getQrCodeImage")
    public void getQrCodeImage() {
        String content = "我爱你中国!" ;
        File file = new File("D:/desktop/1.jpg") ;
        String format = "jpg" ;
        GenerateQrCodeUtils.getQrCodeImage(content, file, format);
    }
}
